package com.wskj.workbench.enums;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.wskj.common.enums.BaseEnum;
import lombok.Getter;

import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;


/**
* Filename: SysUserStatusEnum.java
* Description: 状态枚举类
* Copyright: Copyright (c) 2016-2019 All Rights Reserved. 
* Company: wsdz.com Inc.
*
* @author: guqk
* @version: 1.0 
* Create at: 2022/8/16 14:15 
*
* Modification History: 
* Date Author Version Description 
* ------------------------------------------------------------------ 
* 2022/8/16 guqk 1.0 1.0 Version 
*/
@Getter
public enum SysUserStatusEnum implements BaseEnum<String> {
    /** 0-正常 */
    NORMAL("0","正常"),
    /** 1-停用 */
    STOP("1","停用"),
    /** 2-注销 */
    LOGOFF("2","注销")
    ;

    @EnumValue
    private String value;

    private String desc;

    SysUserStatusEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @JsonCreator
    public static SysUserStatusEnum parse(String param) {
        if (Objects.isNull(param)) {
            return null;
        }
        for (SysUserStatusEnum item : SysUserStatusEnum.values()) {
            if (item.value.equals(param) || item.name().equals(param)) {
                return item;
            }
        }
        return null;
    }

    @JsonValue
    @Override
    public String toString() {
        Map<String,Object> map = new LinkedHashMap<>(2);
        map.put("value",this.value);
        map.put("desc",this.desc);
        String jsonString = JSONUtil.toJsonStr(map);
        return jsonString;
    }
}
